﻿// Author:					HungNM
// Created:					16-08-2012
// Last Modified:			16-08-2012
//

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eProject.Business;


namespace eProject.Web.UI
{
    public partial class AdminMenu : System.Web.UI.UserControl
    {
        private bool IsAdmin = false;
        private Users user = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadParams();
            LoadSettings();
            PopulateLabels();
            PopulateControls();
        }

        private void PopulateControls()
        {

        }


        private void PopulateLabels()
        {
            if (IsPostBack) return;
            user = SiteUser.getCurrentUser();
            if(user == null)
                Response.Redirect("~/Login.aspx");

            if (user.Roles == 1)
                IsAdmin = true;

            lnkHome.Text = "Home";
            if (!IsAdmin)
                lnkHome.NavigateUrl = "~/Admin/";
            else
                lnkHome.NavigateUrl = "~/Member/";

            if (!IsAdmin)
                lnkCity.Visible = false;
            lnkCity.Text = "City";
            lnkCity.NavigateUrl = "~/Admin/CitiesManagementProgram.aspx";
            lnkAddCity.Text = "Add City";
            lnkAddCity.NavigateUrl = "~/Admin/CitiesManagementAddNew.aspx";
            lnkCityManagement.Text = "Management";
            lnkCityManagement.NavigateUrl = "~/Admin/CitiesManagementProgram.aspx";

            if (!IsAdmin)
                lnkCompany.Visible = false;
            lnkCompany.Text = "Company";
            lnkCompany.NavigateUrl = "~/Admin/CompanyManagementProgram.aspx";
            lnkAddCompany.Text = "Add Company";
            lnkAddCompany.NavigateUrl = "~/Admin/CompanyManagementAddNew.aspx";
            lnkCompanyManagement.Text = "Management";
            lnkCompanyManagement.NavigateUrl = "~/Admin/CompanyManagementProgram.aspx";

            if (!IsAdmin)
                lnkPlane.Visible = false;
            lnkPlane.Text = "Plane";
            lnkPlane.NavigateUrl = "~/Admin/PlanesManagementProgram.aspx";
            lnkAddPlane.Text = "Add Plane";
            lnkAddPlane.NavigateUrl = "~/Admin/PlanesManagementAddNew.aspx";
            lnkPlaneManagement.Text = "Management";
            lnkPlaneManagement.NavigateUrl = "~/Admin/PlanesManagementProgram.aspx";

            if (!IsAdmin)
                lnkAirPort.Visible = false;
            lnkAirPort.Text = "AirPort";
            lnkAirPort.NavigateUrl = "~/Admin/AirPortsManagementPro.aspx";
            lnkAddAirPort.Text = "Add AirPort";
            lnkAddAirPort.NavigateUrl = "~/Admin/AirPortManagementAddNew.aspx";
            lnkAirPortManagement.Text = "Management";
            lnkAirPortManagement.NavigateUrl = "~/Admin/AirPortsManagementPro.aspx";

            if (!IsAdmin)
                lnkRoute.Visible = false;
            lnkRoute.Text = "Route";
            lnkRoute.NavigateUrl = "~/Admin/RoutesManagement.aspx";
            lnkAddRoute.Text = "Add Route";
            lnkAddRoute.NavigateUrl = "~/Admin/AddRoute.aspx";
            lnkRouteManagement.Text = "Management";
            lnkRouteManagement.NavigateUrl = "~/Admin/RoutesManagement.aspx";

            if (!IsAdmin)
                lnkOrder.Visible = false;
            lnkOrder.Text = "Order";
            lnkOrder.NavigateUrl = "~/Admin/Order.aspx";
            lnkOrderManagement.Text = "Management";
            lnkOrderManagement.NavigateUrl = "~/Admin/OrderManagement.aspx";

            if (!IsAdmin)
                lnkUser.Visible = false;
            lnkUser.Text = "User";
            lnkUser.NavigateUrl = "~/Admin/UserManagement.aspx";
            lnkAddUser.Text = "Add User";
            lnkAddUser.NavigateUrl = "~/Admin/AddUser.aspx";
            lnkUserManagement.Text = "Management";
            lnkUserManagement.NavigateUrl = "~/Admin/UserManagement.aspx";

            lnkLogout.Text = "Logout";
            lnkLogout.NavigateUrl = "~/Logout.aspx";
        }

        private void LoadSettings()
        {

        }

        private void LoadParams()
        {

        }

        #region OnInit

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Load += new EventHandler(this.Page_Load);
        }

        #endregion
    }
}